<?php
session_start();
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ArticleService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/WoodService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/LineService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/AgingService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/BankService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/OrderService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ColourService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/OrderDetailsService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/StatisticService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ArticlepriceService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/AuthenticationService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/PaymentService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/PermitService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/EmailService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/UserService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ModuleService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/PermitService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/AccountService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/BankAccountService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ShippmentPlanService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ShipmentService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ReportService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/OrderDetailstempService.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Context/BaseContext.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/ServiceResult/ServiceResult.php';

require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../_config/setting/global.setting.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../_config/setting/SMTPConfig.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../_config/setting/orderNumber.php';

if (!file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'../_config/setting/PageConfig.php'))
{
	echo "Configuration file not found!";
}
else
{
	require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../plugin/Config/Config.php';
}
if(isset($_GET['type']) && isset($_GET['action']))
{
	$context = new BaseContext();
	$result = new ServiceResult();
	$moduleService = new ModuleService();
	$permitService = new PermitService();
	$type = $_GET['type'];
	$action = $_GET['action'];
	if(isset($_SESSION['user']['type']))
	{
		$moduleID = $moduleService->getModuleIDByFuncAndOpt($context, $result, $type, $action);
		$permit = $permitService->checkPermition($context, $result, $_SESSION['user']['type'], $moduleID);
	}
	switch ($type) {
		case "user":
			include 'process/user.php';
			break;
				
		case "fact":
			include 'process/fact.php';
			break;
				
		case "cus":
			include 'process/cus.php';
			break;

		case "pass":
			include 'process/pass.php';
			break;
				
		case "bank":
			include 'process/bank.php';
			break;

		case "article":
			include 'process/article.php';
			break;
				
		case "order":
			include 'process/order.php';
			break;
				
		case "purchaseOrder":
			include 'process/purchaseOrder.php';
			break;
				
		case "l":
			include 'process/l.php';
			break;
				
		case "config":
			include 'process/config.php';
			break;

		case "ship":
			include 'process/ship.php';
			break;
				
		case "pi":
			include 'process/pi.php';
			break;
				
		case "payment":
			include 'process/payment.php';
			break;
				
		case "web":
			include 'process/web.php';
			break;
			
		case "invoice":
			include 'process/invoice.php';
			break;
			
		case "report":
			include 'process/report.php';
			break;
				
		default:
			echo "khong co tinh nang nay";
			break;
	}
}
else
{
	echo "ERROR";
}